Trend formatter
Allow users to comprehend trends (positive, negative, or neutral) in numerical data, shown within highlights and tables.
#Variants
The TrendFormatter consists of an icon arrow colored red, green, or gray to indicate whether the change is negative, positive, or neutral, respectively. It's accompanied by a number next to the arrow that displays the specific value of the change (e.g., "+5%", "-3.2%").
<TrendFormatter value={42} referenceValue={41} variant="green-positive" />
<TrendFormatter value={41} referenceValue={42} variant="green-positive" />
<TrendFormatter value={42} referenceValue={42} variant="green-positive" />
<br />
<TrendFormatter value={42} referenceValue={41} variant="red-positive" />
<TrendFormatter value={42} referenceValue={43} variant="red-positive" />
<TrendFormatter value={42} referenceValue={42} variant="red-positive" />
<br />
<TrendFormatter value={42} referenceValue={41} variant="neutral" />
<TrendFormatter value={41} referenceValue={42} variant="neutral" />
<TrendFormatter value={42} referenceValue={42} variant="neutral" />#Alignment
The TrendFormatter offers flexible alignment options, allowing you to position the trend indicator to the left or right of the numerical value. Choose the alignment that best complements the surrounding content and layout.
<TrendFormatter value={42} referenceValue={41} alignment="left" />
<TrendFormatter value={42} referenceValue={41} alignment="right" />#BaseTrendFormatter
The BaseTrendFormatter is a fundamental building block for creating custom trend indicators. It provides a standardized structure and default styling that can be easily extended and customized to match your specific design requirements.
<BaseTrendFormatter value={42} direction="down" color="green" />
<BaseTrendFormatter value={42} direction="down" color="red" />
<BaseTrendFormatter value={42} direction="down" color="gray" />
<br />
<BaseTrendFormatter value={42} direction="up" color="green" />
<BaseTrendFormatter value={42} direction="up" color="red" />
<BaseTrendFormatter value={42} direction="up" color="gray" />
<br />
<BaseTrendFormatter value={42} direction="neutral" />
<br />
<BaseTrendFormatter value={42} direction="down" color="green" alignment="right" />
<BaseTrendFormatter value={42} direction="down" color="red" alignment="right" />
<BaseTrendFormatter value={42} direction="down" color="gray" alignment="right" />
<br />
<BaseTrendFormatter value={42} direction="up" color="green" alignment="right" />
<BaseTrendFormatter value={42} direction="up" color="red" alignment="right" />
<BaseTrendFormatter value={42} direction="up" color="gray" alignment="right" />
<br />
<BaseTrendFormatter value={42} direction="neutral" alignment="left" />
<BaseTrendFormatter value={42} direction="neutral" alignment="right" />#Properties
#TrendFormatter
| Property | Description | Defined | Value |
|---|---|---|---|
valueRequired | numberThe trend value | ||
referenceValueRequired | numberThe reference value | ||
classNameOptional | stringCustom className that's applied to the outermost element (only intended for special cases) | ||
onKeyDownOptional | functionCallback for onKeyDown event | ||
onBlurOptional | functionCallback for onBlur event | ||
onMouseDownOptional | functionCallback for onMouseDown event | ||
aria-describedbyOptional | stringID of an an element that describes the trend content | ||
aria-labelOptional | stringLabel of the trend | ||
aria-labelledbyOptional | stringID of an an element that labels this trend | ||
data-observe-keyOptional | stringUnique string, used by external script e.g. for event tracking | ||
styleOptional | objectStyle object to apply custom inline styles (only intended for special cases) | ||
colorOptional | stringThe arrow color | ||
alignmentOptional | "left" | "right"Whether the arrow comes before or after the number | ||
tabIndexOptional | numberTab index of the outermost HTML element of the component | ||
onMouseEnterOptional | functionCallback for onMouseEnter event | ||
onMouseLeaveOptional | functionCallback for onMouseLeave event | ||
onFocusOptional | functionCallback for onFocus event | ||
variantOptional | "green-positive" | "neutral" | "red-positive" |
#BaseTrendFormatter
| Property | Description | Defined | Value |
|---|---|---|---|
valueRequired | | string | numberThe trend value | ||
directionRequired | "down" | "neutral" | "up"The arrow orientation | ||
colorOptional | stringThe arrow color | ||
alignmentOptional | "left" | "right"Whether the arrow comes before or after the number | ||
aria-labelOptional | stringLabel of the trend | ||
aria-labelledbyOptional | stringID of an an element that labels this trend | ||
aria-describedbyOptional | stringID of an an element that describes the trend content | ||
data-observe-keyOptional | stringUnique string, used by external script e.g. for event tracking | ||
classNameOptional | stringCustom className that's applied to the outermost element (only intended for special cases) | ||
styleOptional | objectStyle object to apply custom inline styles (only intended for special cases) | ||
tabIndexOptional | numberTab index of the outermost HTML element of the component | ||
onKeyDownOptional | functionCallback for onKeyDown event | ||
onMouseDownOptional | functionCallback for onMouseDown event | ||
onMouseEnterOptional | functionCallback for onMouseEnter event | ||
onMouseLeaveOptional | functionCallback for onMouseLeave event | ||
onFocusOptional | functionCallback for onFocus event | ||
onBlurOptional | functionCallback for onBlur event |
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications